import _ from 'lodash'

// options
export const options = {
  filters: {
    activeBool (bool) {
      return bool ? '收起' : '展开'
    },
  },

  props: {
    groups: {
      type: Array,
      default: () => [],
    },
    open: {
      type: Boolean,
      default: () => true,
    },
  },

  data () {
    return {
      active: true,
      iconName: 's iconfont icon-sanjiaoxing',
      activeName: '1',
    }
  },

  computed: {
    fileds () {
      return { name: this.label, generator: this.groups }
    },
    formGenerator () {
      return this.$refs.formGenerator
    },
    collectInfo () {
      return this.formGenerator.collectInfo
    },
  },

  methods: {
    validate () {
      const { getElementAttribute } = this.formGenerator
      return getElementAttribute('validate')
    },

    // 改变折叠版
    triggerCell () {
      if (!this.open) return false

      this.active = !this.active
      setTimeout(() => {
        this.$emit('action')
      }, 300)
    },

    // 获取元素
    getElements () {
      const { getElements } = this.$refs.formGenerator

      return getElements()
    },
  },
}

export default {
  mixins: [options],
}
